package com.oig.sys.base.dao;

import com.oig.sys.base.entity.TbCurrRateHis;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbCurrRateHisDao extends JpaRepository<TbCurrRateHis, Integer> {

    @Query("select c from TbCurrRateHis c where c.currency in :currList and date_format(c.hisTime, '%Y-%m-%d') = :date " +
            "order by c.hisTime desc")
    List<TbCurrRateHis> findAllByCurrAndDate(@Param("currList")List<String> currList, @Param("date") String date);

    List<TbCurrRateHis> findAllByCurrency(String currency);

    @Query("select c from TbCurrRateHis c where c.currency in :currList and  date_format(c.rateTime, '%Y-%m') = :yearMonth and c.customsFlag = :customsFlag order by c.hisTime desc")
    List<TbCurrRateHis> findAllByCurrAndYearMonth(@Param("currList")List<String> currList, @Param("yearMonth") String yearMonth,
                                                  @Param("customsFlag")String customsFlag);
}
